package org.drools.examples.person;

import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;


public class PersonExample {
    public static final void main(final String[] args) {
        KieServices ks = KieServices.Factory.get();
        KieContainer kc = ks.getKieClasspathContainer();
        execute( kc );
    }
    public static void execute( KieContainer kc ) {
        KieSession ksession = kc.newKieSession("PersonExampleKS");      
        
        Person p1 = new Person("白展堂", 68);  
        Person p2 = new Person("李大嘴", 32);  
        Person p3 = new Person("佟湘玉", 18);  
        Person p4 = new Person("郭芙蓉", 8);  
  
        System.out.println("before p1 : " + p1);  
        System.out.println("before p2 : " + p2);  
        System.out.println("before p3 : " + p3);  
        System.out.println("before p4 : " + p4);  
  
        ksession.insert(p1);  
        ksession.insert(p2);  
        ksession.insert(p3);  
        ksession.insert(p4);  
        
        int count = ksession.fireAllRules();
        System.out.println("总执行了"+count+"条规则");  
        System.out.println("after p1 : " + p1);  
        System.out.println("after p2 : " + p2);  
        System.out.println("after p3 : " + p3);  
        System.out.println("after p4 : " + p4);
        ksession.dispose();
    }
}
  
